import request from '@/utils/request'

// 查询地区表列表
export function listRegion (query) {
  return request({
    url: '/platform/region/list',
    method: 'get',
    params: query
  })
}

// 查询地区表详细
export function getRegion (id) {
  return request({
    url: '/platform/region/' + id,
    method: 'get'
  })
}

// 查询地区表详细(包含版块、地图)
export function getRegionDetail (id) {
  return request({
    url: '/platform/region/regionDetail/' + id,
    method: 'get'
  })
}


// 新增地区表
export function addRegion (data) {
  return request({
    url: '/platform/region',
    method: 'post',
    data: data
  })
}
// 地区审核
export function approveRegion (data) {
  return request({
    url: '/platform/region/approve',
    method: 'post',
    data: data
  })
}


// 修改地区表
export function updateRegion (data) {
  return request({
    url: '/platform/region',
    method: 'put',
    data: data
  })
}

// 删除地区表
export function delRegion (id) {
  return request({
    url: '/platform/region/' + id,
    method: 'delete'
  })
}


// 校验地区编码是否存在
export function checkCodeUnique (id, code) {
  if (id === undefined) {
    id = ''
  }
  return request({
    url: '/platform/region/checkCodeUnique/' + code + '/' + id,
    method: 'get'
  })
}


// 导出地区表
export function exportRegion (query) {
  return request({
    url: '/platform/region/export',
    method: 'get',
    params: query
  })
}

// 获取初始化数据
export function getInitData (dictTypes) {
  return request({
    url: '/platform/region/getInitData/' + dictTypes,
    method: 'get'
  })
}
